home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / answrbok / 4_8.lha / 4_8 / 4_8A.h < prev    next >
Text File  |  1993-08-08  |  914b  |  49 lines

  1. * Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
  2. * The C++ Answer Book */
  3. * Tony Hansen */
  4. * All rights reserved. */
  5. * Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
  6. * The C++ Answer Book */
  7. * Tony Hansen */
  8. * All rights reserved. */
  9. / stack.h
  10. / define a module of routines
  11. / which manipulate a stack
  12. ifndef STACK_H
  13.  define STACK_H
  14. ypedef int stacktype;
  15. ypedef struct
  16.    {
  17.    int maxsize;
  18.    int curtop;
  19.    stacktype *mem;
  20.    } stack;
  21.  
  22. / create a new stack
  23. tack *newstack(int maxsize);
  24.  
  25. / delete the stack
  26. oid delstack(stack *s);
  27.  
  28. / add val onto stack
  29. oid push(stack *s, stacktype c);
  30.  
  31. / return and remove top of stack
  32. tacktype pop(stack *s);
  33.  
  34. / return top of stack
  35. tacktype top(stack *s);
  36.  
  37. / empty the stack
  38. nline void clearstack(stack *s)
  39.  
  40.    s->curtop = 0;
  41.  
  42.  
  43. / see if stack is empty
  44. nline int isempty(stack *s)
  45.  
  46.    return s->curtop == 0;
  47.  
  48. endif /* STACK_H */
  49.